//
//  TravelDetailTVCell.m
//  WildDonkey
//
//  Created by 佟小波 on 15/3/27.
//  Copyright (c) 2015年 lanou. All rights reserved.
//

#import "TravelDetailTVCell.h"
#import "UIImageView+WebCache.h"

@implementation TravelDetailTVCell

- (void)dealloc
{
    [_sj_textLabel release];
    [_sj_textLabel release];
    [_sj_picView release];
    [super dealloc];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        CGRect rect = [UIScreen mainScreen].bounds;
        
        CGFloat width = rect.size.width;
        CGFloat height=rect.size.height;
        //底层视图
        UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(10, 10, width - 20, 287)];
        bgView.backgroundColor = [UIColor clearColor];
        
        //白底毛玻璃效果层
        UIView *bgView1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, width - 20, 287)];
        [bgView1 setBackgroundColor:[UIColor blackColor]];
        bgView1.alpha = 0.5;
        [bgView addSubview:bgView1];
        
        //图片
        _sj_picView = [[UIImageView alloc] initWithFrame:CGRectMake(5, 5, width-30, 110)];
        _sj_picView.layer.cornerRadius = 10;
        //        _sj_picView.backgroundColor = [UIColor redColor];
        _sj_picView.alpha = 0.8;
        _sj_picView.layer.masksToBounds = YES;
        [bgView addSubview:_sj_picView];
        
        //标题
        _sj_titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 120, width-30, 30)];
        //        _sj_titleLabel.backgroundColor = [UIColor blueColor];
        _sj_titleLabel.numberOfLines = 1;
        _sj_titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
        _sj_titleLabel.font = [UIFont systemFontOfSize:18];
        _sj_textLabel.textColor = [UIColor greenColor];
        [bgView addSubview:_sj_titleLabel];
        
        //简介
        _sj_textLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 160, width-30, 120)];
        //        _sj_textLabel.backgroundColor = [UIColor redColor];
        _sj_textLabel.numberOfLines = 0;
        _sj_textLabel.lineBreakMode = NSLineBreakByTruncatingTail;
        _sj_textLabel.font = [UIFont systemFontOfSize:14];
        _sj_textLabel.textColor=[UIColor whiteColor];
        [bgView addSubview:_sj_textLabel];
        
        
        [self.contentView addSubview:bgView];
        [bgView release];
        
    }
    return self;
}

//当外部更改了单元格的高度时,调用
//- (void)layoutSubviews
//{
//    NSLog(@"%f",self.frame.size.height);
//    _heightChanged=self.frame.size.height;
//}

-(void)setTravelDetail:(TravelDetail *)travelDetail
{
    if (_travelDetail!=travelDetail) {
        [_travelDetail release];
        _travelDetail=[travelDetail retain];
        
        _sj_titleLabel.textColor=[UIColor greenColor];
        _sj_titleLabel.text=travelDetail.title;
        _sj_textLabel.text=travelDetail.desc;
        
        [_sj_picView setImageWithURL:[NSURL URLWithString:travelDetail.img]];
        
    }
}


@end
